package com.be.beadmin.basicData.entity;

import com.be.beadmin.common.entity.BaseEntity;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Getter;
import lombok.Setter;
import net.minidev.json.annotate.JsonIgnore;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * @author chenwei
 * @date 2/23/2023 2:06 PM
 * 组织机构表
 */
@Entity
@Table(name="T_BASEDATA_ORGANIZATION")
@Getter
@Setter

public class Organization extends BaseEntity {

    @Column(name = "OrgName",columnDefinition = "VARCHAR(32) COMMENT '组织名称' ")
    private String orgName;

    @Column(name = "OrgCode",columnDefinition = "VARCHAR(32) COMMENT '组织编码' ")
    private String orgCode;

    @JsonManagedReference
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "PARENT_ID",columnDefinition = "VARCHAR(32) COMMENT '父菜单' ")
    private Organization parentOrg;


    @JsonBackReference
    @OneToMany(mappedBy = "parentOrg", fetch = FetchType.LAZY)
    private List<Organization> childOrgs = new ArrayList<>();

}
